/**
 * 处理二维数组又两种最基本的方法 按列访问 和按行访问
 * 如下
 */
// 学生平均成绩
const grades  = [[77,88,99],[89,67,81],[55,76,66],[34,78,99]]
getStudentAverage = function(grades){
  let average = 0
  let averages = []
  for (let row = 0; row < grades.length; row++) {
    let total = 0
    for (let col = 0; col < grades[row].length; col++) {
        total +=  grades[row][col]
    }
    average = (total/grades[row].length).toFixed(2)
    averages.push(average)
  }
  return averages
}
// 各科平均成绩 。
// 这个明显不能作为计算各科平均成绩的方法。这里要能正确计算就必须是 内层数组和外层数组一样大。这里实际是以内层数组循环再取万层数组的值
const grades1  = [[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4]]
getSubjectAverage = function(grades){
  let average = 0
  let averages = []
  for (let row = 0; row < grades.length; row++) {
    let total = 0
    for(let col = 0;col<grades[row].length;col++){
      total+= grades[col][row]
    }
    average = (total/grades[row].length).toFixed(2)
    averages.push(average)
  }
  return averages
}